<?php
namespace yifang\response;

use yifang\lib\Cookie;
use yifang\lib\Request;

/**
 * Redirect Response
 */
class Redirect extends Response
{

    protected $request;

    public function __construct(Cookie $cookie, Request $request,$data = '', int $code = 302)
    {
        $this->init((string) $data, $code);

        $this->cookie  = $cookie;
        $this->request = $request;

        $this->cacheControl('no-cache,must-revalidate');
    }

    /**
     * 处理数据
     * @param mixed $data
     * @param $templatePath
     * @access protected
     * @return string
     */
    protected function output($data, $templatePath)
    {
        $this->header['Location'] = $data;

        return '';
    }
}
